package com.advance.springcloud.user.controller;

import com.advance.springcloud.commons.dto.UserDTO;
import com.advance.springcloud.user.holder.LoginUserHolder;
import com.advance.springcloud.commons.domain.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private LoginUserHolder loginUserHolder;

    @GetMapping("/test")
    public String hello(){
        return "hello";
    }

    @GetMapping("currentUser")
    public CommonResult<UserDTO> currentUser(){
        return CommonResult.success(loginUserHolder.getCurrentUser());
    }

}
